package org.honeyweb.gsoc.pages;

import java.util.ArrayList;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.Service;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.honeyweb.gsoc.model.Honeypots;
import org.honeyweb.gsoc.model.Organizations;
import org.honeyweb.gsoc.model.Users;
import org.honeyweb.gsoc.services.HoneypotsManager;
import org.honeyweb.gsoc.services.OrganizationsManager;

public class ListHoneypot {

	private final Log logger = LogFactory.getLog(ListHoneypot.class);
	
	@Inject
	@Service("organizationsManager")
	private OrganizationsManager organizationsManager;
	
	@Inject
	@Service("honeypotsManager")
	private HoneypotsManager honeypotsManager;
	
	@SessionState(create=true)
	private Users user;
	
	@Property
	@InjectComponent
	private Zone listHoneypots;
	
	@Property
	private String continent;
	
	@Property
	private String availibility;
	
	@Property
	private Honeypots honeypotLoop;
	
	public ArrayList<Honeypots> getHoneypots() {
		int userId = user.getIdUser();
		Organizations organization = organizationsManager.getOrganizationByAdminId(userId);
		logger.debug("Organization name:"+organization.getName());
		return honeypotsManager.getHoneypots(organization);
	}
	
	
	public String onSuccess(){
		return "scheduler";
	}
}
